using System;
using System.Data;

namespace Data.Model
{
    public class jsh_account
    {
        public Int64 id { get; set; }
        public string cpuid { get; set; }
        public string cpuno { get; set; }
        public string username { get; set; }
        public string sex { get; set; }
        public string cardtype { get; set; }
        public string status { get; set; }
        public string nation { get; set; }
        public string zzlx { get; set; }
        public string zzhm { get; set; }
        public string fzdw { get; set; }
        public string sdate { get; set; }
        public string edate { get; set; }
        public string telephone { get; set; }
        public string mobile { get; set; }
        public string addr1 { get; set; }
        public string addr2 { get; set; }
        public string khdate { get; set; }
        public string validate { get; set; }
        public Decimal deposit { get; set; }
        public Decimal balance { get; set; }
        public Double credit { get; set; }
        public string password { get; set; }
        public string ver { get; set; }
        public string type { get; set; }
        public string operator1 { get; set; }
        public Int64 operatorid { get; set; }
        public DateTime closedate { get; set; }
        public string memo { get; set; }
        public byte[] photo { get; set; }

        private string InsertSql = "insert into jsh_account([id],[cpuid],[cpuno],[username],[sex],[cardtype],[status],[nation],[zzlx],[zzhm],[fzdw],[sdate],[edate],[telephone],[mobile],[addr1],[addr2],[khdate],[validate],[deposit],[balance],[credit],[password],[ver],[type],[operator],[operatorid],[closedate],[memo],[photo]) values(@id,@cpuid,@cpuno,@username,@sex,@cardtype,@status,@nation,@zzlx,@zzhm,@fzdw,@sdate,@edate,@telephone,@mobile,@addr1,@addr2,@khdate,@validate,@deposit,@balance,@credit,@password,@ver,@type,@operator,@operatorid,@closedate,@memo,@photo)";
        private string UpdateSql = "UPDATE jsh_account SET [id]=@id,[cpuid]=@cpuid,[cpuno]=@cpuno,[username]=@username,[sex]=@sex,[cardtype]=@cardtype,[status]=@status,[nation]=@nation,[zzlx]=@zzlx,[zzhm]=@zzhm,[fzdw]=@fzdw,[sdate]=@sdate,[edate]=@edate,[telephone]=@telephone,[mobile]=@mobile,[addr1]=@addr1,[addr2]=@addr2,[khdate]=@khdate,[validate]=@validate,[deposit]=@deposit,[balance]=@balance,[credit]=@credit,[password]=@password,[ver]=@ver,[type]=@type,[operator]=@operator,[operatorid]=@operatorid,[closedate]=@closedate,[memo]=@memo,[photo]=@photo";

        private bool _tranByConstructFlag = false;
        public bool TranByConstructFlag { get { return _tranByConstructFlag; } set { _tranByConstructFlag = value; } }
        public jsh_account(DataRow dataRow)
        {
            if (dataRow != null)
            {
                try
                {
                    this.id = dataRow["id"] is DBNull ? 0 : Convert.ToInt64(dataRow["id"]);
                    this.cpuid = dataRow["cpuid"] is DBNull ? string.Empty : Convert.ToString(dataRow["cpuid"]);
                    this.cpuno = dataRow["cpuno"] is DBNull ? string.Empty : Convert.ToString(dataRow["cpuno"]);
                    this.username = dataRow["username"] is DBNull ? string.Empty : Convert.ToString(dataRow["username"]);
                    this.sex = dataRow["sex"] is DBNull ? string.Empty : Convert.ToString(dataRow["sex"]);
                    this.cardtype = dataRow["cardtype"] is DBNull ? string.Empty : Convert.ToString(dataRow["cardtype"]);
                    this.status = dataRow["status"] is DBNull ? string.Empty : Convert.ToString(dataRow["status"]);
                    this.nation = dataRow["nation"] is DBNull ? string.Empty : Convert.ToString(dataRow["nation"]);
                    this.zzlx = dataRow["zzlx"] is DBNull ? string.Empty : Convert.ToString(dataRow["zzlx"]);
                    this.zzhm = dataRow["zzhm"] is DBNull ? string.Empty : Convert.ToString(dataRow["zzhm"]);
                    this.fzdw = dataRow["fzdw"] is DBNull ? string.Empty : Convert.ToString(dataRow["fzdw"]);
                    this.sdate = dataRow["sdate"] is DBNull ? string.Empty : Convert.ToString(dataRow["sdate"]);
                    this.edate = dataRow["edate"] is DBNull ? string.Empty : Convert.ToString(dataRow["edate"]);
                    this.telephone = dataRow["telephone"] is DBNull ? string.Empty : Convert.ToString(dataRow["telephone"]);
                    this.mobile = dataRow["mobile"] is DBNull ? string.Empty : Convert.ToString(dataRow["mobile"]);
                    this.addr1 = dataRow["addr1"] is DBNull ? string.Empty : Convert.ToString(dataRow["addr1"]);
                    this.addr2 = dataRow["addr2"] is DBNull ? string.Empty : Convert.ToString(dataRow["addr2"]);
                    this.khdate = dataRow["khdate"] is DBNull ? string.Empty : Convert.ToString(dataRow["khdate"]);
                    this.validate = dataRow["validate"] is DBNull ? string.Empty : Convert.ToString(dataRow["validate"]);
                    this.deposit = dataRow["deposit"] is DBNull ? 0 : Convert.ToDecimal(dataRow["deposit"]);
                    this.balance = dataRow["balance"] is DBNull ? 0 : Convert.ToDecimal(dataRow["balance"]);
                    this.credit = dataRow["credit"] is DBNull ? 0 : Convert.ToDouble(dataRow["credit"]);
                    this.password = dataRow["password"] is DBNull ? string.Empty : Convert.ToString(dataRow["password"]);
                    this.ver = dataRow["ver"] is DBNull ? string.Empty : Convert.ToString(dataRow["ver"]);
                    this.type = dataRow["type"] is DBNull ? string.Empty : Convert.ToString(dataRow["type"]);
                    this.operator1 = dataRow["operator"] is DBNull ? string.Empty : Convert.ToString(dataRow["operator"]);
                    this.operatorid = dataRow["operatorid"] is DBNull ? 0 : Convert.ToInt64(dataRow["operatorid"]);
                    this.closedate = dataRow["closedate"] is DBNull ? DateTime.Now : Convert.ToDateTime(dataRow["closedate"]);
                    this.memo = dataRow["memo"] is DBNull ? string.Empty : Convert.ToString(dataRow["memo"]);
                    this.photo = dataRow["photo"] is DBNull ? new byte[0] : (byte[])dataRow["photo"];
                    this.TranByConstructFlag = true;
                }
                catch (Exception) { this.TranByConstructFlag = false; }
            }
        }
        public jsh_account() { }
    }
}
